-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added ignoring interfaces via -exclude_interfaces flag (#68) #72
Conversation
Thanks for contribution @tulzke, i'm happy to discuss here or in the ticket but I think the the exclusion list as a mockgen flag parameter is the best approach as (1) command line flags are current mechanism by which mock options are configured and (2) users won't be required to modify their source code to take advantage of the feature. |
@r-hang , thanks for reply. Yes, I can do this via the flag parameter. |
01264d0
to
78bb101
Compare
@tulzke how about |
@r-hang, sounds good. I have already committed this. |
@tulzke the core logic looks could to me. However, could we add some tests for the newly added parseExcludeInterfaces function? |
…plementation of the function
@r-hang good point. I added a unit test for the function, and then changed the implementation to satisfy the test cases. |
This is a proposal PR to generate mocks without error for following cases: ```go type Water[R any, C UnsignedInteger] interface { Fish(R) []C } type UnsignedInteger interface { ~uint | ~uint32 | ~uint64 } ``` Go `types` package seems to wrap interfaces that contain type constraints by checking a type set literal of the form `~T` and `A|B`. https://github.com/golang/go/blob/master/src/go/types/decl.go#L668 So gomock can just ignore that pattern to generate mocks safely without `don't know how to mock method of type` errors. I think this can be a better solution for custom type constraints than [`-exclude` flag](#72). --------- Co-authored-by: Jacob Oaks <[email protected]>
I forgot to do this when I created the last PR #72
The problem is described in the issue. This is one of the solutions to this problem.